<!DOCTYPE html>
<link href="css/default.css" rel="stylesheet" type="text/css">
<html>
<head>
<meta charset="ISO-8859-1">
<title>Creating the database and the database schema</title>
</head>
<body>
<h1>Creating the database and the database schema</h1>

<p>Once you have the source, you can configure PostgreSQL and create the database schema.
Our goals are the following:</p>
<ol>
	<li>Create a database called "<tt>openempi</tt>"</li>
	<li>create a role (=user) named "<tt>openempi</tt>"
	(by default we use the password "<tt>openempi</tt>" too)</li>
	<li>The owner of the openempi database should be this <tt>openempi</tt> user</li>
	<li>Create database schema</li>
</ol>
<p>Most of the steps can be performed with the PgAdmin III GUI tool. For another explanation please
refer to <a href="http://kenai.com/projects/openempi/pages/InstallationInstructions">OpenEMPI instructions</a>.</p>
<p>You may need to change the postgres DB role's password, see
<a href="http://www.ubuntugeek.com/howto-setup-database-server-with-postgresql-and-pgadmin3.html">this</a>
(ALTER USER part).</p>
<p>You probably want to tweak postgresql config too: see <tt>/etc/postgresql/{8.4|9.1}/main/postgresql.conf</tt>
<ul>
<li><tt>password_encryption="on"</tt></li>
<li>If you want postgresql to listen to not only localhost: <tt>listen_adress="*"</tt></li>
</ul>
</p>

<p>Series of commands (bold) and server responses (regular) and comments (italic) in case of
psql prompt. <a href="db_get_psql_prompt.html">Get to the psql prompt</a>.
At the prompt:
<ul>
	<li><b>(!not needed by default, only if the postgres role has a password set and got forgotten)</b>
		<i>change 'postgres' password:</i></li>
	<li><tt>postgres=# <b>ALTER USER postgres WITH ENCRYPTED PASSWORD 'myhardtoguesspassword';</b></tt></li>
	<li><tt>ALTER ROLE</tt></li>
	<li><i>Perform the first three steps mentioned before:</i></li>
	<li><tt>postgres=# <b>CREATE DATABASE openempi;</b></tt></li>
	<li><tt>CREATE DATABASE</tt></li>
	<li><tt>postgres=# <b>CREATE USER openempi WITH ENCRYPTED PASSWORD 'openempi';</b></tt></li>
	<li><tt>CREATE ROLE</tt></li>
	<li><tt>postgres=# <b>GRANT ALL PRIVILEGES ON DATABASE openempi TO openempi;</b></tt></li>
	<li><tt>GRANT</tt></li>
</ul>
</p>

<p><a href="db_schema_create.html">To create the database schema follow this link</a>.

</body>
</html>